package com.example.controller;

import com.example.pojo.Result;
import com.example.service.chineseTripService;
import com.example.pojo.chineseTripPojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class chineseTripController {
    @Autowired
    private chineseTripService chineseTripService;

    // Post query for all Clerk Names
    @PostMapping("/queryAllChineseTrip")
    public Result queryAllChineseTrip() {
        // Query all Clerk Names
        List<chineseTripPojo> chineseTripPojoList = chineseTripService.queryAll();
        System.out.println("Query successful");
        return Result.success(chineseTripPojoList);
    }

    // Post method to add a new Clerk Name
    @PostMapping("/addChineseTrip")
    public Result addChineseTrip(@RequestBody chineseTripPojo chineseTripPojo) {
        System.out.println("Adding Clerk Name: " + chineseTripPojo);
        chineseTripService.insertOne(chineseTripPojo);
        System.out.println("Addition successful");
        return Result.success();
    }

    // Post method to edit an existing Clerk Name
    @PostMapping("/editChineseTrip")
    public Result editChineseTrip(@RequestBody chineseTripPojo chineseTripPojo) {
        chineseTripService.editChineseTrip(chineseTripPojo);
        System.out.println("Edit successful");
        return Result.success("Edit successful");
    }




}
